/*
    静态代理总结：
        1、真实对象和代理对象都要实现同一个接口
        2、代理对象代理真实角色
    好处：
        1、代理对象可以做很多真实对象做不了的事
        2、真实对象专注做自己的事
 */
public class StaticProxy {
    public static void main(String[] args) {
//        WeddingCompany weddingCompany = new WeddingCompany(new You());
        You you = new You();

        new Thread( ()-> System.out.println("我爱你")).start();
        WeddingCompany weddingCompany = new WeddingCompany(you);
        weddingCompany.HappyMarry();
    }
}

interface Marry {
    void HappyMarry();
}

//真实角色
class You implements Marry {

    @Override
    public void HappyMarry() {
        System.out.println("要结婚了，开心！");
    }
}

//代理角色
class WeddingCompany implements Marry {
    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void after() {
        System.out.println("收尾款！");
    }

    private void before() {
        System.out.println("布置现场");
    }
}
